import javazoom.jl.player.*;
import javazoom.jl.decoder.*;
import java.io.*;

public class MP3Player1 {

 private Player player;
 private InputStream stream;
 
 /** Creates a new instance of MP3Player */
 public MP3Player1(String filename) 
 {
  try
  {
   // Create an InputStream to the file
   stream = new FileInputStream(filename);
  }
  catch(Exception e)
  {
   e.printStackTrace();
  }
 }
 
 public void play()
 {
  try
  {
   player = new Player(stream);
   PlayerThread pt = new PlayerThread();
   pt.start();
   while(!player.isComplete())
   {
    int position = player.getPosition();
    System.out.println("Position: " + position);
    try
    {
     Thread.sleep( 1000 );
    }
    catch(Exception ee)
    {
     ee.printStackTrace();
    }
   }
  }
  catch( Exception e )
  {
   e.printStackTrace();
  }
 }
 
 class PlayerThread extends Thread
 {
  public void run()
  {
   try
   {
    player.play();
   }
   catch(Exception e)
   {
    e.printStackTrace();
   }
  }
 }
 
    
    public static void main( String[] args )
    {
	try{
	    if(args.length == 0)
		{	
		    System.out.println( "Usage: MP3Player <filename>");
		    System.exit( 0 );
		}
	    
	    MP3Player1 mp3Player = new MP3Player1("test.mp3");
	    mp3Player.play();
	}
	catch(Exception e){System.out.println("banana");}
    }
}